* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 24px;
    color: #333;
    font-weight: 600;
}

.indices-container {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.index-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.index-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.index-info {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.index-value {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.index-change {
    font-size: 12px;
    font-weight: 500;
}

.index-change.positive {
    color: #f44336;
}

.index-change.negative {
    color: #4CAF50;
}

.stats-container {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stat-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
}

.main-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.add-item-container {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.input-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.group-select {
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    min-width: 150px;
    background: white;
}

.add-group-btn {
    padding: 12px 20px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.add-group-btn:hover {
    background: #1976D2;
}

#itemInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

#itemInput:focus {
    outline: none;
    border-color: #4CAF50;
}

#addItemBtn {
    padding: 12px 24px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#addItemBtn:hover {
    background: #45a049;
}

.error-message {
    color: #f44336;
    font-size: 12px;
    margin-top: 5px;
    height: 16px;
}

.items-container {
    min-height: 200px;
}

.items-list {
    padding: 20px;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.item-card {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 16px;
    border-left: 4px solid #ddd;
    transition: all 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.item-card.positive {
    border-left-color: #f44336;
}

.item-card.negative {
    border-left-color: #4CAF50;
}


.item-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.item-code {
    font-size: 12px;
    color: #666;
    background: #e0e0e0;
    padding: 2px 6px;
    border-radius: 4px;
}

.remove-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s;
}

.remove-btn:hover {
    background: #f44336;
    color: white;
}

.kline-btn {
    background: none;
    border: none;
    color: #2196F3;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s;
    margin-right: 4px;
}

.kline-btn:hover {
    background: #2196F3;
    color: white;
}

.stock-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
}

.stock-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stock-price {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.item-price {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.item-change {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.change-value {
    font-size: 14px;
    font-weight: 600;
}

.change-percent {
    font-size: 12px;
    margin-top: 2px;
}

.positive .change-value,
.positive .change-percent {
    color: #f44336;
}

.negative .change-value,
.negative .change-percent {
    color: #4CAF50;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state p {
    margin-bottom: 10px;
}

.loading {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 5px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.positive #totalChange {
    color: #f44336;
}

.negative #totalChange {
    color: #4CAF50;
}

/* 市场状态样式 */
.market-status {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    margin-left: 8px;
}

.market-status.trading {
    background-color: #4CAF50;
    color: white;
}

.market-status.closed {
    background-color: #999;
    color: white;
}

/* 分组样式 */
.groups-container {
    min-height: 200px;
}

.group-section {
    margin-bottom: 20px;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.group-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.group-header.positive {
    border-left: 4px solid #f44336;
}

.group-header.negative {
    border-left: 4px solid #4CAF50;
}

.group-info {
    flex: 1;
}

.group-name {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 5px 0;
    color: #333;
}

.group-desc {
    font-size: 14px;
    color: #666;
    margin: 0 0 5px 0;
}

.group-count {
    font-size: 12px;
    color: #999;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 12px;
}

.group-stats {
    display: flex;
    align-items: center;
    gap: 20px;
}

.group-change {
    font-size: 18px;
    font-weight: 600;
}

.group-actions {
    display: flex;
    gap: 8px;
}

.btn-edit, .btn-delete, .btn-toggle {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-edit {
    background: #FF9800;
    color: white;
}

.btn-edit:hover {
    background: #F57C00;
}

.btn-delete {
    background: #f44336;
    color: white;
}

.btn-delete:hover {
    background: #d32f2f;
}

.btn-toggle {
    background: #9E9E9E;
    color: white;
}

.btn-toggle:hover {
    background: #757575;
}

.group-content {
    padding: 0;
}

.group-empty {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-style: italic;
}


.item-actions {
    display: flex;
    align-items: center;
    margin-left: 20px;
}

.move-select {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    cursor: pointer;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #666;
}

.modal-body {
    padding: 20px;
}

.modal-body input,
.modal-body textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 15px;
    box-sizing: border-box;
}

.modal-body input:focus,
.modal-body textarea:focus {
    outline: none;
    border-color: #4CAF50;
}

.modal-body textarea {
    min-height: 80px;
    resize: vertical;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8f9fa;
}

.modal-footer button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-footer button.primary {
    background: #4CAF50;
    color: white;
}

.modal-footer button.primary:hover {
    background: #45a049;
}

.modal-footer button:not(.primary) {
    background: #f0f0f0;
    color: #666;
}

.modal-footer button:not(.primary):hover {
    background: #e0e0e0;
}

/* K线图悬浮容器样式 */
.kline-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    min-width: 320px;
    max-width: 400px;
    display: none;
    overflow: hidden;
}

.kline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.kline-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.kline-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.kline-close:hover {
    background: #f0f0f0;
    color: #666;
}

.kline-chart {
    padding: 20px;
    text-align: center;
    background: white;
}

.kline-loading {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.kline-error {
    padding: 40px 20px;
    text-align: center;
    color: #f44336;
    font-size: 14px;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .indices-container {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .index-item {
        width: 100%;
        max-width: 200px;
    }

    .stats-container {
        justify-content: center;
    }

    .input-group {
        flex-direction: column;
        gap: 10px;
    }

    .group-select {
        min-width: auto;
    }

    #addItemBtn, .add-group-btn {
        width: 100%;
    }

    .items-grid {
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .item-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .stock-info {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .stock-price {
        align-items: flex-start;
        width: 100%;
    }

    .item-actions {
        width: 100%;
        justify-content: flex-end;
        margin-left: 0;
        margin-top: 8px;
    }

    .group-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .group-stats {
        flex-direction: column;
        gap: 10px;
    }

    .group-actions {
        justify-content: center;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }
}